# -*- coding: utf-8 -*-
"""
@Time: 2024/11/10 21:56
@Auth: Zhang Hongxing
@File: sense.py
@Note:   
"""
from vaderSentiment.vaderSentiment import SentimentIntensityAnalyzer

def analyze_sentiment(text):
    analyzer = SentimentIntensityAnalyzer()
    sentiment_score = analyzer.polarity_scores(text)
    if sentiment_score['compound'] >= 0.05:
        return 'positive'
    elif sentiment_score['compound'] <= -0.05:
        return 'negative'
    else:
        return 'neutral'

if __name__ == '__main__':
    text = "I am so happy today!"
    print(analyze_sentiment(text))
    text = "I am so sad today!"
    print(analyze_sentiment(text))
    text = "I am so so today!"
    print(analyze_sentiment(text))